<?php
ini_set('error_reporting', e_notice);
include_once "inc_function.php";
include_once '../../function/class_tabel_paging.php';

	
session_start();

	$current_page = 1;
	if(isset($_GET['page'])){
		$current_page = $_GET['page'];
	}
	$page_per_row1 = 10;
	$start_myrow = ($current_page-1) * $page_per_row1 + 1;
	$end_row = $current_page * $page_per_row1;
	
	$sql_count = "SELECT COUNT(*) AS num_rows FROM VIEW_COUNTRY_CITY where city_id > 0 order by city_id asc";
	$headerValue = array(
		'OTHER' => array('ID' => 'CITY_ID'),				
		'TABLE' => array(
			'CITY CODE' => 'CITY_CODE',
			'CITY NAME' => 'CITY_NAME',
			'COUNTRY NAME' => 'COUNTRY_NAME'
		 )		
	);
	
	$search = (isset($_REQUEST['search'])) ?$_REQUEST['search']:''; 
	
	$sql1 = array(
		'sql_result' => "BEGIN PKG_MASTER.sp_get_city_by_name(:str_city_name,:int_start_row,:int_end_row,:cursor);END;",
		'condition' => array(
			':int_start_row' => $start_myrow,
			':int_end_row' => $end_row,
			':str_city_name' => $search,
			':cursor' => ''	
		)
	);
	$form = AJAX_PATH."form_city.php";
	$paging = new tabel_paging($con,$sql_count,$page_per_row1,$sql1,$headerValue);
    $total_rows = $paging->count_rows($con,$sql_count);
    $total_mypages = $paging->total_pages($total_rows, $page_per_row1);    
?>
<script>
   function cekValue(id,c_name){
      window.parent.window.get_employee(id,c_name);
      self.parent.tb_remove();
   }
</script>
<body>

<fieldset class="list_login">
   <legend> Dashboard List City</legend>
   <form action method='get' id=form_search>
	<div>Search : <input type='text' name='search' class='text_search' placeholder='search...' /></div>
	</form>
   <?php echo $paging->paged_result($con,$start_myrow,$page_per_row1,$sql1,$headerValue,$form); ?>
<div class="left">
<a href="<?= $form;?>" class="button left"> Create New </a>
<span class="right"><?php  echo $paging->draw_pager(AJAX_PATH."list_city.php", $total_mypages, $current_page);?></span>
</div>   
</fieldset>
</body>